home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
timing.arc
/
TIMERS.BAS
< prev
next >
Wrap
BASIC Source File
|
1987-10-01
|
3KB
|
71 lines
'$MODULE: 'TIMERS'
'$INCLUDE: 'fnCTICKS.def'
'*****************************************************************************
'*** DELAY - performs a "hard" delay.
SUB DELAY (HUN.SCNDS!) STATIC
'$MODULE: 'DELAY'
'input: an integer representing the number of hundredth-seconds to delay
'delay == input: HUN.SCNDS! = hundredths of seconds
'$INCLUDE: 'TICKS.def'
START.TIME! = FNCTICKS(0) ' mark the current time
ENDING.TIME!= FNCTICKS(HUN.SCNDS!) ' mark the ending time
IF ENDING.TIME! < START.TIME! THEN
ENDING.TIME! = ENDING.TIME! + TICKS.PER.DAY!
end if
do
CURRENT.TIME! = FNCTICKS(0) ' mark the current time
if current.time! < start.time! then
current.time! = current.time! + ticks.per.day!
end if
loop until current.time! >= ending.time!
EXIT SUB
END SUB
'*** end of DELAY
'*****************************************************************************
'*****************************************************************************
'*** BGDELAY - performs a background delay, returning control to the caller
'*** after each check so that the caller may be doing something
'*** while waiting.
SUB BGDELAY (HUN.SCNDS!,HUN.SCNDS.TO.GO!,STATUS%) STATIC
'$MODULE: 'bgDELAY'
'input: an integer representing the number of hundredth-seconds to delay
'delay == input: HUN.SCNDS! = hundredths of seconds
' output: HUN.SCNDS.TO.GO! = hundredths of seconds until timeout
' output: STATUS% = 0 - delay is complete; 1 - delay is continuing
'$INCLUDE: 'TICKS.def'
STATIC START.TIME!,ENDING.TIME!
IF STATUS% = 0 THEN 'entering for the first time this request
START.TIME! = FNCTICKS(0) ' mark the current time
ENDING.TIME! = FNCTICKS(HUN.SCNDS!) ' mark the ending time
IF ENDING.TIME! < START.TIME! THEN
ENDING.TIME! =ENDING.TIME! + TICKS.PER.DAY!
end if
end if
CURRENT.TIME! = FNCTICKS(0)
IF CURRENT.TIME! < START.TIME! THEN
CURRENT.TIME! = CURRENT.TIME! + TICKS.PER.DAY!
end if
TICKS.LEFT! = ENDING.TIME! - CURRENT.TIME! 'calculate ticks left to go
HUN.SCNDS.TO.GO! = (TICKS.LEFT!*100)/TICKS.PER.SEC! ' see Tech.Ref.
IF TICKS.LEFT! > 0 THEN
status%=1 ' time has NOT run out
else
status%=0 ' delay is complete
end if
exitsub:
EXIT SUB
END SUB
'*** end of BGDELAY
'*****************************************************************************